home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Essentials / MacApp Documentation / MacApp.TECH$ Archives / 1990 / Jan 90 / MacApp.Tech$ 1⁄26⁄90 / 0554-Writing resource for-Jan90 < prev    next >
Encoding:
Text File  |  1991-03-06  |  1.5 KB  |  48 lines  |  [TEXT/GEOL]

  1. Item    2775304                         26-Jan-90        15:44PST
  2.  
  3. From:   DAWSON.M                        Dawson, Mark
  4.  
  5. To:     MACAPP.TECH$                    MacApp Technical
  6.  
  7. Sub:    Writing resource forks
  8.  
  9. I've got a question regarding adding resources to a file.  I used the
  10. DemoText.p example file as an example, but mine wouldn't work…I got a FFC3
  11. error (-63/WrPermission error) the first AddResource call I made.
  12.  
  13. Example code:
  14.    numChars := GetHandleSize(fDocText);
  15.    FailOSErr(FSWrite(aRefNum, numChars, fDocText^));
  16.  
  17.    IF fTEView.fStyleType = kWithStyle THEN
  18.    BEGIN
  19.    fTEView.ExtractStyles(styles, elements);
  20.    FailOSErr(HandToHand(Handle(styles)));
  21.    AddResource(Handle(styles), kTextStyleRsrcType, kStylesRsrcID, '');
  22.    FailResError;
  23.    END;
  24.  
  25. My code (in C++):
  26.    longdataBytes;
  27.  
  28.    inherited::DoWrite(aRefNum, makingCopy);
  29.     dataBytes = GetHandleSize(fTextHdl);
  30.     FailOSErr(FSWrite(aRefNum, &dataBytes, *fTextHdl));// write data to disk
  31.   Handle aHandle;
  32.   FailOSErr(PtrToHand((Ptr)&"\pHello world",&aHandle,12)); // copy hdr into a
  33.    AddResource(aHandle, 'mtst', 1, (Str255)"\p");
  34.     FailResError();
  35.     DisposIfHandle(aHandle);
  36.  
  37. Is there something I'm missing?  The DemoText example uses a NULL ('') string
  38. as the file name; I assume tell the Mac OS to use the file that is open?
  39.  
  40. What's the procedure for writing resource data out when the data's being writen
  41. out?  (It may be some misuse/lack of understanding of C++ && MacApp).
  42.  
  43.  
  44. Thanks,
  45.  
  46.      Mark
  47.  
  48.